﻿using Architecture.Api.Application.Command.RoleCommand;
using Architecture.Domain;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RelatedAddCommandHandler : IRequestHandler<RelatedAddCommand, int>
    {
        protected readonly IRoleService _roleService;

        public RelatedAddCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RelatedAddCommand request, CancellationToken cancellationToken)
        {
            var UserId = request.userId;
            var roleId = new Related() { RoleId=request.roleId };
            var RoleId =roleId.RoleId;
            return await _roleService.GetRelatedAdd(RoleId,UserId);
        }
    }
}
